package com.qys.livesMall.shop.controller.sys;

import com.qys.livesMall.common.result.R;
import com.qys.livesMall.shop.modal.entity.ShopRechargeGradient;
import com.qys.livesMall.shop.modal.vo.ShopRechargeGradientVO;
import com.qys.livesMall.shop.service.ShopRechargeGradientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 后台-店铺充值返现梯度
 *
 * @author
 * @since 2023-10-24
 */
@RestController
@RequestMapping("/sys/shop/rechargeGradient")
public class SysShopRechargeGradientController {

    @Autowired
    private ShopRechargeGradientService shopRechargeGradientService;

    /**
     * 获取所有分割区间
     * @return
     */
    @GetMapping("/getAll")
    public R<List<ShopRechargeGradientVO>> getAll(){
        return R.ok(shopRechargeGradientService.getAll());
    }

    /**
     * 新增和编辑
     * @param gradient
     * @return
     */
    @PostMapping("/addOrUp")
    public R addOrUp(@RequestBody ShopRechargeGradient gradient){
        shopRechargeGradientService.addOrUp(gradient);
        return R.ok();
    }

    /**
     * 生效或者失效
     * @param gradient
     * @return
     */
    @PostMapping("/upStatus")
    public R upStatus(@RequestBody ShopRechargeGradient gradient){
        shopRechargeGradientService.upStatus(gradient);
        return R.ok();
    }
}
